using System;
using System.Collections.Generic;

namespace EstimationStudio.Core
{
	/// <summary>
	///  The ProjectPhase class is used to represents the error variability or a particular phase
	///  in the requirements gathering process.
	/// </summary>
	[Serializable]
	public class ProjectPhase
	{
		/// <summary>
		/// Initializes a new instance of the <see cref="ProjectPhase"/> class.
		/// </summary>
		public ProjectPhase () 
        {
            Name = String.Empty;
            ErrorVariability = new ErrorVariability(0, 0);
        }

		/// <summary>
		/// Initializes a new instance of the <see cref="ProjectPhase"/> class.
		/// </summary>
		/// <param name="name">A unique name for this phase.</param>
		/// <param name="errorVariability">The error variability rate for this phase.</param>
		/// <remarks>Unique names are not enforced.</remarks>
		public ProjectPhase (String name, ErrorVariability errorVariability)
		{
			Name = name;
			ErrorVariability = errorVariability;
		}

		/// <summary>
		///  Gets or Sets the name of this <see cref="Rating"/>.
		/// </summary>
        public String Name { get; set; }

		/// <summary>
		///  Gets or Sets the error variability rate of this <see cref="Rating"/>.
		/// </summary>
		public ErrorVariability ErrorVariability { get; set; }

        /// <summary>
        ///  Overrides the base ToString Method.
        /// </summary>
        /// <returns>A string representation of this ProjectPhase</returns>
        public override string ToString()
        {
            return String.Format("{0}: {1}", Name, ErrorVariability);
        }

        /// <summary>
        ///  Overrides the base equality comparison method.
        /// </summary>
        /// <param name="obj">The object to compare to.</param>
        /// <returns>True if the name of this project phase matches the name of the project phase passed in. False if the object is not of type ProjectPhase.</returns>
        public override bool Equals(object obj)
        {
            var projectPhase = obj as ProjectPhase;
            if (projectPhase == null)
                return false;

            return projectPhase.Name == this.Name;
        }
	}
}